package com.gator.desig_mode.mvc2;

import java.lang.annotation.Annotation;

public interface HandlerAdapter {

  //匹配当前handler
  public boolean support(Object handler);

  //执行对应handler方法
  public void doHandler(Object handler);

}

class HttpAdapter implements HandlerAdapter {

  @Override
  public boolean support(Object handler) {
    return (handler instanceof HttpHandler);
  }

  @Override
  public void doHandler(Object handler) {
    ((HttpHandler) handler).doHandler();
  }
}

class SimpleAdapter implements HandlerAdapter {

  @Override
  public boolean support(Object handler) {
    return (handler instanceof SimpleHandler);
  }

  @Override
  public void doHandler(Object handler) {
    ((SimpleHandler) handler).doHandler();
  }

}

class AnnotationAdapter implements HandlerAdapter {

  @Override
  public boolean support(Object handler) {
    return (handler instanceof AnnotationHandler);
  }

  @Override
  public void doHandler(Object handler) {
    ((AnnotationHandler) handler).doHandler();
  }
}
